<?php

function getNumsGroupArr($RateConfig_5h, $rateArr, $numUnion, $pounArr, $toaArr = array ())
{
    $reNullArr = array ();
    $toaFlag = count($toaArr);
    switch ($numUnion)
    {
        case 1 :
            if ($toaFlag)
            {
                return $reNullArr;
            }
            $reNumArr = array ();
            foreach ($pounArr as $val)
            {
                $reNumArr[] = array ($RateConfig_5h->getRateFromRateArr("", $val, $rateArr), array ($val));
            }
            return $reNumArr;
        case 2 :
            if ($toaFlag)
            {
                if (count($pounArr) != 1)
                {
                    return $reNullArr;
                }
                $toaArrL = count($toaArr);
                $tempArr = "";
                $reNumArr = array ();
                $tempRate = $RateConfig_5h->getRateFromRateArr("", $pounArr[0], $rateArr);
                $i = 0;
                if ($i < $toaArrL)
                {
                    $tempArr = array ($pounArr[0], $toaArr[$i]);
                    sort($tempArr);
                    $reNumArr[] = array (min($tempRate, $RateConfig_5h->getRateFromRateArr("", $toaArr[$i], $rateArr)), $tempArr);
                    ++$i;
                }
                return $reNumArr;
            }
            $reNumArr = array ();
            $pounArrL = count($pounArr);
            $tempArr = "";
            $i = 0;
            while ($i < $pounArrL)
            {
                $j = $i + 1;
                while ($j < $pounArrL)
                {
                    $tempArr = array ($pounArr[$i], $pounArr[$j]);
                    sort($tempArr);
                    $reNumArr[] = array (min($RateConfig_5h->getRateFromRateArr("", $pounArr[$i], $rateArr), $RateConfig_5h->getRateFromRateArr("", $pounArr[$j], $rateArr)), $tempArr);
                    ++$j;
                }
                ++$i;
            }
            return $reNumArr;
        case 3 :
            if ($toaFlag)
            {
                if (count($pounArr) != 2)
                {
                    return $reNullArr;
                }
                $toaArrL = count($toaArr);
                $tempArr = "";
                $reNumArr = array ();
                $tempRate = $RateConfig_5h->getRateFromRateArr("", array ($pounArr[0], $pounArr[1]), $rateArr);
                $i = 0;
                while ($i < $toaArrL)
                {
                    $tempArr = array ($pounArr[0], $pounArr[1], $toaArr[$i]);
                    sort($tempArr);
                    $reNumArr[] = array (min($tempRate, $RateConfig_5h->getRateFromRateArr("", $toaArr[$i], $rateArr)), $tempArr);
                    ++$i;
                }
                return $reNumArr;
            }
            $reNumArr = array ();
            $pounArrL = count($pounArr);
            $tempArr = "";
            $tempRateI = 0;
            $tempRateJ = 0;
            $i = 0;
            while ($i < $pounArrL)
            {
                $tempRateI = $RateConfig_5h->getRateFromRateArr("", $pounArr[$i], $rateArr);
                $j = $i + 1;
                while ($j < $pounArrL)
                {
                    $tempRateJ = $RateConfig_5h->getRateFromRateArr("", $pounArr[$j], $rateArr);
                    $k = $j + 1;
                    while ($k < $pounArrL)
                    {
                        $tempArr = array ($pounArr[$i], $pounArr[$j], $pounArr[$k]);
                        sort($tempArr);
                        $reNumArr[] = array (min($tempRateI, $tempRateJ, $RateConfig_5h->getRateFromRateArr("", $pounArr[$k], $rateArr)), $tempArr);
                        ++$k;
                    }
                    ++$j;
                }
                ++$i;
            }
            return $reNumArr;
        case 4 :
            if ($toaFlag)
            {
                if (count($pounArr) != 3)
                {
                    return $reNullArr;
                }
                $toaArrL = count($toaArr);
                $tempArr = "";
                $reNumArr = array ();
                $tempRate = $RateConfig_5h->getRateFromRateArr("", array ($pounArr[0], $pounArr[1], $pounArr[2]), $rateArr);
                $i = 0;
                while ($i < $toaArrL)
                {
                    $tempArr = array ($pounArr[0], $pounArr[1], $pounArr[2], $toaArr[$i]);
                    sort($tempArr);
                    $reNumArr[] = array (min($tempRate, $RateConfig_5h->getRateFromRateArr("", $toaArr[$i], $rateArr)), $tempArr);
                    ++$i;
                }
                return $reNumArr;
            }
            $reNumArr = array ();
            $pounArrL = count($pounArr);
            $tempArr = "";
            $tempRateI = 0;
            $tempRateJ = 0;
            $tempRateK = 0;
            $i = 0;
            while ($i < $pounArrL)
            {
                $tempRateI = $RateConfig_5h->getRateFromRateArr("", $pounArr[$i], $rateArr);
                $j = $i + 1;
                while ($j < $pounArrL)
                {
                    $tempRateJ = $RateConfig_5h->getRateFromRateArr("", $pounArr[$j], $rateArr);
                    $k = $j + 1;
                    while ($k < $pounArrL)
                    {
                        $tempRateK = $RateConfig_5h->getRateFromRateArr("", $pounArr[$k], $rateArr);
                        $l = $k + 1;
                        while ($l < $pounArrL)
                        {
                            $tempArr = array ($pounArr[$i], $pounArr[$j], $pounArr[$k], $pounArr[$l]);
                            sort($tempArr);
                            $reNumArr[] = array (min($tempRateI, $tempRateJ, $tempRateK, $RateConfig_5h->getRateFromRateArr("", $pounArr[$l], $rateArr)), $tempArr);
                            ++$l;
                        }
                        ++$k;
                    }
                    ++$j;
                }
                ++$i;
            }
            return $reNumArr;
        case 5 :
            if ($toaFlag)
            {
                if (count($pounArr) != 4)
                {
                    return $reNullArr;
                }
                $toaArrL = count($toaArr);
                $tempArr = "";
                $reNumArr = array ();
                $tempRate = $RateConfig_5h->getRateFromRateArr("", array ($pounArr[0], $pounArr[1], $pounArr[2], $pounArr[3]), $rateArr);
                $i = 0;
                while ($i < $toaArrL)
                {
                    $tempArr = array ($pounArr[0], $pounArr[1], $pounArr[2], $pounArr[3], $toaArr[$i]);
                    sort($tempArr);
                    $reNumArr[] = array (min($tempRate, $RateConfig_5h->getRateFromRateArr("", $toaArr[$i], $rateArr)), $tempArr);
                    ++$i;
                }
                return $reNumArr;
            }
            $reNumArr = array ();
            $pounArrL = count($pounArr);
            $tempArr = "";
            $tempRateI = 0;
            $tempRateJ = 0;
            $tempRateK = 0;
            $tempRateL = 0;
            $i = 0;
            while ($i < $pounArrL)
            {
                $tempRateI = $RateConfig_5h->getRateFromRateArr("", $pounArr[$i], $rateArr);
                $j = $i + 1;
                while ($j < $pounArrL)
                {
                    $tempRateJ = $RateConfig_5h->getRateFromRateArr("", $pounArr[$j], $rateArr);
                    $k = $j + 1;
                    while ($k < $pounArrL)
                    {
                        $tempRateK = $RateConfig_5h->getRateFromRateArr("", $pounArr[$k], $rateArr);
                        $l = $k + 1;
                        while ($l < $pounArrL)
                        {
                            $tempRateL = $RateConfig_5h->getRateFromRateArr("", $pounArr[$l], $rateArr);
                            $m = $l + 1;
                            while ($m < $pounArrL)
                            {
                                $tempArr = array ($pounArr[$i], $pounArr[$j], $pounArr[$k], $pounArr[$l], $pounArr[$m]);
                                sort($tempArr);
                                $reNumArr[] = array (min($tempRateI, $tempRateJ, $tempRateK, $tempRateL, $RateConfig_5h->getRateFromRateArr("", $pounArr[$m], $rateArr)), $tempArr);
                                ++$m;
                            }
                            ++$l;
                        }
                        ++$k;
                    }
                    ++$j;
                }
                ++$i;
            }
            return $reNumArr;
    }
    return $reNullArr;
}

function getNumsGroupSArr($RateConfig_5h, $rateArr, $numUnion, $numArr)
{
    $reNullArr = array ();
    $numArrL = count($numArr);
    if ($numArrL != $numUnion)
    {
        return $reNullArr;
    }
    switch ($numUnion)
    {
        case 2 :
            $reNumArr = array ();
            $tempArr = "";
            $tempRate0 = 0;
            $tempRate1 = 0;
            $numArr0L = count($numArr[0]);
            $numArr1L = count($numArr[1]);
            $i = 0;
			if($numArr0L==1&& $numArr1L==1) return array();
            while ($i < $numArr0L)
            {
                $tempRate0 = $RateConfig_5h->getRateFromRateArr("", $numArr[0][$i], $rateArr);
                $j = 0;
                while ($j < $numArr1L)
                {
                    if ($numArr[0][$i] != $numArr[1][$j])
					{
                    	$tempRate1 = $RateConfig_5h->getRateFromRateArr("", $numArr[1][$j], $rateArr);
                    	$tempArr = array ($numArr[0][$i], $numArr[1][$j]);
                    	$reNumArr[] = array (min($tempRate0, $tempRate1), $tempArr);
					}
                    ++$j;
                }
                ++$i;
            }
			
            return $reNumArr;
        case 3 :
            $reNumArr = array ();
            $tempArr = "";
            $tempRate0 = 0;
            $tempRate1 = 0;
            $tempRate2 = 0;
            $numArr0L = count($numArr[0]);
            $numArr1L = count($numArr[1]);
            $numArr2L = count($numArr[2]);
            for ($i = 0; $i < $numArr0L; $i++)
            {
                $tempRate0 = $RateConfig_5h->getRateFromRateArr("", $numArr[0][$i], $rateArr);
                for ($j = 0; $j < $numArr1L; $j++)
                {
                    if ($numArr[0][$i] == $numArr[1][$j])
                    {
                        continue;
                    }
                    $tempRate1 = $RateConfig_5h->getRateFromRateArr("", $numArr[1][$j], $rateArr);
                    for ($k = 0; $k < $numArr2L; $k++)
                    {
                        if ($numArr[0][$i] == $numArr[2][$k])
                        {
                            continue;
                        }
                        if ($numArr[1][$j] == $numArr[2][$k])
                        {
                            continue;
                        }
                        $tempRate2 = $RateConfig_5h->getRateFromRateArr("", $numArr[2][$k], $rateArr);
                        $tempArr = array ($numArr[0][$i], $numArr[1][$j], $numArr[2][$k]);
                        $reNumArr[] = array (min($tempRate0, $tempRate1, $tempRate2), $tempArr);
                    }
                }
            }
            return $reNumArr;
        default :
            return $reNullArr;
    }
    return $reNullArr;
}

if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
if (!ispost())
{
    exit();
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chk = new CheckMode_3d($curruser['acl'], 5, $gametype);
$chk->checkShow3dPage();
$betname_5h = judge_type($gametype);
unset($chk);
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
if (20 < $gametype)
{
    $_8hFlag = true;
}
else
{
    $_8hFlag = false;
}
require_once( "class_5h/RateConfig_5h.php" );
require_once( "class_5h/SRate_5h.php" );
$ui = new UI_3D(true);
$conf = new Config();
$RateConfig_5h = new RateConfig_5h($gametype);
$SRate_5h = new SRate_5h($gametype);
$today = date("Y-m-d");
$bettypegroup = getvar("palygroup");
unset($_POST['bettypegroup']);
$pounNum = $RateConfig_5h->pounNum;
$rcbettype = 0;
$betmin = intval($conf->get("betmin_{$tbl}"));
$betmin2face = intval($conf->get("betmin2face_{$tbl}"));
if ($betmin2face <= 0)
{
    $betmin2face = $betmin;
}
if ($curruser['enabled'] == 0 || $curruser['enabled'] == 2)
{
    $ui->showErrorPage("帐号已被暂停使用");
    exit();
}
else if (1 < $curruser['acl'])
{
    $ui->showErrorPage("非会员无法下注");
    exit();
}
$disk = intval(getvar("disk"));
if (!isset($curruser["disk{$disk}"]) || $curruser["disk{$disk}"] != 1)
{
    $ui->showErrorPage("盘类错误");
    exit();
}
unset($_POST['disk']);
$diskStr = $RateConfig_5h->diskArr[$disk];
$diskStr2 = $g_disk_name[$disk];
if ($bettypegroup == "" || !isset($RateConfig_5h->playGroupArr[$bettypegroup]))
{
    $ui->showErrorPage("{$tblName}-不正确的玩法页面");
    exit();
}
$xyidGet = isset($_POST['xyid']) ? intval(getvar("xyid")) : 0 - 1;
unset($_POST['xyid']);
$subid = 0 - 1;
$bettype = 0 - 1;
$nums = "";
include_once( "BetChk.php" );
$BetChk = new BetChk($today, $gametype);
if ($lotto = $BetChk->chkBetDate($today))
{
    $lotto_id = $lotto['id'];
    $round = $lotto['round'];
    $showBetTable = array ();
    $rateArr = array ();
    $amountsDataArr = array ();
    $user_id = $SRate_5h->getAcl5ID($curruser['id'], $curruser['acl']);
    unset($RateConfig_5h->xyidTitle[0]);
    if ($gametype == 24)
    {
        $rcArr = array ();
        $subIDBetArr = array (0, 1, 2, 5, 6);
        $subidOKArr = array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        $num2Word = array (0, 5);
    }
    else
    {
        if ($_8hFlag)
        {
            $rcArr = array (10, 11, 12, 13, 14, 15, 16, 17);
            $subIDBetArr = array (0, 1, 2, 3, 4, 5, 6);
            $subidOKArr = array (1, 2, 3, 4, 5, 6, 7, 8);
            $num2Word = array (0, 10, 11, 12, 13, 14, 15, 16, 17);
        }
        else
        {
            $rcArr = array (9, 10, 11, 12, 13, 14);
            $subIDBetArr = array (0, 1, 2, 3, 4, 5, 6);
            $subidOKArr = array (1, 2, 3, 4, 5);
            $num2Word = array (0, 9, 10, 11, 12, 13, 14);
        }
    }

    foreach ($_POST as $key => $val)
    {
        $betOKFlag = true;
        $tempArr = array ();
        $val = intval($val);
        if (empty($val) || $val < 1)
        {
            $betOKFlag = false;
            continue;
        }
        $dataArrTemp = explode("_", $key);
        if (count($dataArrTemp) != 4)
        {
            $betOKFlag = false;
            continue;
        }
        $subid = 0 - 1;
        $bettype = 0 - 1;
        $nums = "";
        $err = 0;
        if (array_key_exists($dataArrTemp[2], $g_betname_5h[$gametype]))
        {
            $bettype = intval($dataArrTemp[2]);
        }
        else
        {
            $err = 1;
        }
        if (in_array($bettype, $rcArr))
        {
            ++$err;
            continue;
        }
        if (in_array($dataArrTemp[2], $subIDBetArr))
        {
            $subid = intval($dataArrTemp[1]);
            if (!in_array($subid, $subidOKArr))
            {
                $betOKFlag = false;
                $timeTemp = rand(0, 9999);
                $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-8 会员下注:不正确的subid:xyid-{$xyidGet}, subid-{$subid}, bettype-{$bettype}";
                write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$dataArrTemp[2]})");
                ++$err;
                exit();
            }
        }
        else
        {
            $subid = 0;
        }
        $betnameIdx = $bettype . "_" . $subid;
        if (!isset($betname_5h[$betnameIdx]))
        {
            $betOKFlag = false;
            $timeTemp = rand(0, 9999);
            $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-9 会员下注:不正确的玩法类别:xyid-{$xyidGet}, subid-{$subid}, bettype-{$bettype}";
            write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
            $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
            ++$err;
            exit();
        }
        if (in_array($bettype, $g_betXYArr[$gametype]))
        {
            $xyid = $xyidGet;
            if (in_array($xyidGet, array (1, 2)))
            {
                $xyid = $xyidGet;
            }
            else
            {
                $betOKFlag = false;
                $timeTemp = rand(0, 9999);
                $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-9 会员下注:不正确的xyid:xyid-{$xyidGet}, subid-{$subid}, bettype-{$bettype}";
                write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
                exit();
            }
        }
        else
        {
            $xyid = 0;
        }
        if (in_array($bettype, $num2Word))
        {
            $nums = d2(intval($dataArrTemp[3]));
        }
        else
        {
            $nums = intval($dataArrTemp[3]) . "";
        }
        if ($err)
        {
            $betOKFlag = false;
            $timeTemp = rand(0, 9999);
            $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-1 会员下注:不正确的格式:xyid-{$xyid}, subid-{$subid}, bettype-{$bettype}, nums-{$nums}";
            write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
            $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
            exit();
        }
        else if (!$RateConfig_5h->checkBetNumber($bettype, $nums))
        {
            $betOKFlag = false;
            $timeTemp = rand(0, 9999);
            $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-2 会员下注:不正确的内容:id-" . $bettype . ",num-" . $nums;
            write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
            $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
            exit();
        }
        $betmin_tmp = in_array($bettype, $g_2face_5h[$gametype]) ? $betmin2face : $betmin;
        $betnameIdx = $bettype . "_" . $subid;
        if ($val < $betmin_tmp)
        {
            $betOKFlag = false;
            $showBetTable[] = array ("xyid" => $xyid, "subid" => $subid, "bettype" => $betname_5h[$betnameIdx], "nums" => $RateConfig_5h->getBetContent($bettype, $nums), "rate" => "--", "betmoney" => "<font class=\"red\">下注金额不能小於最低限额({$betmin_tmp}元)</font>", "betflag" => false);
            continue;
        }
        if (!isset($rateArr[$betnameIdx]))
        {
            $tempRateBaseArr = $SRate_5h->getRates($lotto_id, $xyid, $disk, $bettype, $subid);
            if ($tempRateBaseArr == false)
            {
                $betOKFlag = false;
                $showBetTable[] = array ("xyid" => $xyid, "subid" => $subid, "bettype" => $betname_5h[$betnameIdx], "nums" => $RateConfig_5h->getBetContent($bettype, $nums), "rate" => "--", "betmoney" => "<font class=\"red\">无赔率资料无法下注</font>", "betflag" => false);
                $errMsg = "({$tbl})会员下注:无该玩法之赔率值:id-{$bettype}, subid-{$subid}";
                write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                continue;
            }
            if ($tempRateBaseArr2 = $SRate_5h->getRatesS($lotto_id, $bettype, $user_id, $subid))
            {
                $tempRateArr = array ();
                foreach ($tempRateBaseArr as $key2 => $val2)
                {
                    $tempRateArr[$key2] = $tempRateBaseArr[$key2] - $tempRateBaseArr2[$key2];
                }
                $rateArr[$betnameIdx] = $tempRateArr;
            }
            else
            {
                $rateArr[$betnameIdx] = $tempRateBaseArr;
            }
        }
        $rate = $RateConfig_5h->getRateFromRateArr($bettype, $nums, $rateArr[$betnameIdx]);
        if ($rate <= 1)
        {
            $betOKFlag = false;
            $showBetTable[] = array ("xyid" => $xyid, "subid" => $subid, "bettype" => $betname_5h[$betnameIdx], "nums" => $RateConfig_5h->getBetContent($bettype, $nums), "rate" => "--", "betmoney" => "<font class=\"red\">赔率值错误无法下注</font>", "betflag" => false);
            $errMsg = "({$tbl})会员下注:赔率值错误:id-{$bettype},num-{$nums}, subid-{$subid}";
            write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
            continue;
        }
        if ($betOKFlag)
        {
            $showBetTable[] = array ("xyid" => $xyid, "subid" => $subid, "bettype" => $betname_5h[$betnameIdx] . "<input type=\"hidden\" name=\"b_{$subid}_{$bettype}_{$nums}\" value=\"{$val}\" />", "nums" => $RateConfig_5h->getBetContent($bettype, $nums), "rate" => $rate . "<input type=\"hidden\" name=\"rate{$bettype}v{$nums}v{$subid}\" value=\"{$rate}\" />", "betmoney" => $val, "betflag" => true);
        }
    }
    if (isset($_POST['quick5h']))
    {
        if ($_8hFlag)
        {
            $rcbettype = intval(getvar("rcbettype"));
            $rxcxOKArr = array ("rc10" => array (10, 1, 2), "rc11" => array (11, 1, 2), "rc12" => array (12, 99999, 2), "rc13" => array (13, 2, 3), "rc14" => array (14, 2, 3), "rc15" => array (15, 99999, 3), "rc16" => array (16, 3, 4), "rc17" => array (17, 4, 5));
            $rxcxChkN = isset($rxcxOKArr[$bettypegroup . $rcbettype]) ? $rxcxOKArr[$bettypegroup . $rcbettype][1] : "-1";
            if (0 - 1 < $rxcxChkN)
            {
                $rxcxData = $rxcxOKArr[$bettypegroup . $rcbettype];
            }
            if ($rcbettype == "12")
            {
                $_POST['quick5h'] = "c";
            }
            else
            {
                if ($rcbettype == "15")
                {
                    $_POST['quick5h'] = "d";
                }
            }
        }
        else
        {
            $rxcxOKArr = array ("r1c1" => array (9, 0, 1), "r2c2" => array (10, 1, 2), "r3c2" => array (11, 2, 3), "r3c3" => array (12, 2, 3), "r4c3" => array (13, 3, 4), "r5c3" => array (14, 4, 5));
            $rxcxChkN = isset($rxcxOKArr[$bettypegroup]) ? $rxcxOKArr[$bettypegroup][1] : "-1";
            if (0 - 1 < $rxcxChkN)
            {
                $rxcxData = $rxcxOKArr[$bettypegroup];
            }
        }
        $B5hTypeMon = max(0, intval(getvar("B5hTypeMon")));
        if ($B5hTypeMon < $betmin || $B5hTypeMon <= 0)
        {
            $ui->showErrorPage("下注失败，下注金额{$B5hTypeMon}小於最低限额{$betmin}");
        }
        if (0 - 1 < $rxcxChkN)
        {
            $bettype = $rxcxData[0];
            $subid = 0;
            $xyid = 0;
            $chkPoun = $rxcxData[2];
            $chkDin = $rxcxData[1];
            $betnameIdx = $bettype . "_" . $subid;
            $numArr = array_intersect(array_unique(explode(",", $_POST['B5hTypeSpan01'])), $RateConfig_5h->getBetTypeNumber($bettype));
            $numArrL = count($numArr);
            $tempRateBaseArr = $SRate_5h->getRates($lotto_id, $xyid, $disk, $bettype, $subid);
            if ($tempRateBaseArr == false)
            {
                $betOKFlag = false;
                $errMsg = "({$tbl})会员下注:无该玩法之赔率值:id-{$bettype}, subid-{$subid}, xyid-{$xyid}";
                write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                $ui->showErrorPage("无赔率资料无法下注");
                exit();
            }
            if ($tempRateBaseArr2 = $SRate_5h->getRatesS($lotto_id, $bettype, $user_id, $subid))
            {
                $tempRateArr = array ();
                foreach ($tempRateBaseArr as $key2 => $val2)
                {
                    $tempRateArr[$key2] = $tempRateBaseArr[$key2] - $tempRateBaseArr2[$key2];
                }
                $rateArr[$betnameIdx] = $tempRateArr;
            }
            else
            {
                $rateArr[$betnameIdx] = $tempRateBaseArr;
            }
            switch ($_POST['quick5h'])
            {
                case "a" :
                    if ($_8hFlag && in_array($bettype, array (12, 15)))
                    {
                        exit();
                    }
                    if ($pounNum < $numArrL)
                    {
                        $timeTemp = rand(0, 9999);
                        $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-4会员下注:异常的碰数({$numArrL}碰)";
                        write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                        $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
                        exit();
                    }
                    if ($numArrL < $chkPoun)
                    {
                        $timeTemp = rand(0, 9999);
                        $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-5会员下注:异常的碰数({$numArrL}碰)";
                        write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                        $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
                        exit();
                    }
                    $numOKarr = getNumsGroupArr($RateConfig_5h, $rateArr[$betnameIdx], $chkPoun, $numArr);
                    $numOKarrL = count($numOKarr);
                    $i = 0;
                    while ($i < $numOKarrL)
                    {
                        $betnameIdx = $bettype . "_0";
                        $nums = implode(",", $numOKarr[$i][1]);
                        $rate = $numOKarr[$i][0];

                        if ($rate < 1)
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx], "nums" => $nums, "rate" => "--", "betmoney" => "<font class=\"red\">赔率值错误无法下注</font>", "betflag" => false);
                        }
                        else
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx] . "<input type=\"hidden\" name=\"b_0_{$bettype}_{$nums}\" value=\"{$B5hTypeMon}\" />", "nums" => $nums, "rate" => $rate . "<input type=\"hidden\" name=\"rate{$bettype}v{$nums}v{$subid}\" value=\"{$rate}\" />", "betmoney" => $B5hTypeMon, "betflag" => true);
                        }
                        ++$i;
                    }
                    break;
                case "b" :
                    if (!isset($_POST['B5hTypeSpan02']))
                    {
                        exit();
                    }
                    if ($_8hFlag && in_array($bettype, array (12, 15)))
                    {
                        exit();
                    }
                    if ($numArrL != $chkDin)
                    {
                        $timeTemp = rand(0, 9999);
                        $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-7会员下注:异常的胆数({$numArrL}胆)";
                        write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                        $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
                        exit();
                    }
                    $toaArr = array_intersect(array_unique(explode(",", $_POST['B5hTypeSpan02'])), $RateConfig_5h->getBetTypeNumber($bettype));
                    $toaArrL = count($toaArr);
                    if (0 < count(array_intersect($toaArr, $numArr)))
                    {
                        $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-6会员下注:重复胆托";
                        write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                        exit();
                    }
                    if ($toaArrL < 1 || $pounNum < $toaArrL)
                    {
                        $timeTemp = rand(0, 9999);
                        $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-9会员下注:异常的托数({$toaArrL}托)";
                        write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                        $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
                        exit();
                    }
                    $numOKarr = getNumsGroupArr($RateConfig_5h, $rateArr[$betnameIdx], $chkPoun, $numArr, $toaArr);
                    $numOKarrL = count($numOKarr);
                    $i = 0;
                    while ($i < $numOKarrL)
                    {
                        $betnameIdx = $bettype . "_0";
                        $nums = implode("", $numOKarr[$i][1]);
                        $rate = $numOKarr[$i][0];
                        if ($rate < 1)
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx], "nums" => $RateConfig_5h->getBetContent($bettype, $numOKarr[$i][1]), "rate" => "--", "betmoney" => "<font class=\"red\">赔率值错误无法下注</font>", "betflag" => false);
                        }
                        else
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx] . "<input type=\"hidden\" name=\"b_0_{$bettype}_{$nums}\" value=\"{$B5hTypeMon}\" />", "nums" => $RateConfig_5h->getBetContent($bettype, $numOKarr[$i][1]), "rate" => $rate . "<input type=\"hidden\" name=\"rate{$bettype}v{$nums}v{$subid}\" value=\"{$rate}\" />", "betmoney" => $B5hTypeMon, "betflag" => true);
                        }
                        ++$i;
                    }
                    break;
                case "c" :
                    if (!$_8hFlag || $bettype != 12)
                    {
                        exit();
                    }
                    $chkNumArr = $RateConfig_5h->getBetTypeNumber($bettype);
                    $numOKarr = getNumsGroupSArr($RateConfig_5h, $rateArr[$betnameIdx], 2, array (array_intersect(array_unique(explode(",", $_POST['B5hTypeSpan01'])), $chkNumArr), array_intersect(array_unique(explode(",", $_POST['B5hTypeSpan02'])), $chkNumArr)));
                    $numOKarrL = count($numOKarr);
                    $i = 0;
                    while ($i < $numOKarrL)
                    {
                        $betnameIdx = $bettype . "_0";
                        $nums = implode("", $numOKarr[$i][1]);
                        $rate = $numOKarr[$i][0];
                        if ($rate < 1)
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx], "nums" => $RateConfig_5h->getBetContent($bettype, $numOKarr[$i][1]), "rate" => "--", "betmoney" => "<font class=\"red\">赔率值错误无法下注</font>", "betflag" => false);
                        }
                        else
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx] . "<input type=\"hidden\" name=\"b_0_{$bettype}_{$nums}\" value=\"{$B5hTypeMon}\" />", "nums" => $RateConfig_5h->getBetContent($bettype, $numOKarr[$i][1]), "rate" => $rate . "<input type=\"hidden\" name=\"rate{$bettype}v{$nums}v{$subid}\" value=\"{$rate}\" />", "betmoney" => $B5hTypeMon, "betflag" => true);
                        }
                        ++$i;
                    }
                    break;
                case "d" :
                    if (!$_8hFlag || $bettype != 15)
                    {
                        exit();
                    }
                    $chkNumArr = $RateConfig_5h->getBetTypeNumber($bettype);
                    $numOKarr = getNumsGroupSArr($RateConfig_5h, $rateArr[$betnameIdx], 3, array (array_intersect(array_unique(explode(",", $_POST['B5hTypeSpan01'])), $chkNumArr), array_intersect(array_unique(explode(",", $_POST['B5hTypeSpan02'])), $chkNumArr), array_intersect(array_unique(explode(",", $_POST['B5hTypeSpan03'])), $chkNumArr)));
                    $numOKarrL = count($numOKarr);
                    $i = 0;
                    while ($i < $numOKarrL)
                    {
                        $betnameIdx = $bettype . "_0";
                        $nums = implode("", $numOKarr[$i][1]);
                        $rate = $numOKarr[$i][0];
                        if ($rate < 1)
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx], "nums" => $RateConfig_5h->getBetContent($bettype, $numOKarr[$i][1]), "rate" => "--", "betmoney" => "<font class=\"red\">赔率值错误无法下注</font>", "betflag" => false);
                        }
                        else
                        {
                            $showBetTable[] = array ("xyid" => 0, "subid" => 0, "bettype" => $betname_5h[$betnameIdx] . "<input type=\"hidden\" name=\"b_0_{$bettype}_{$nums}\" value=\"{$B5hTypeMon}\" />", "nums" => $RateConfig_5h->getBetContent($bettype, $numOKarr[$i][1]), "rate" => $rate . "<input type=\"hidden\" name=\"rate{$bettype}v{$nums}v{$subid}\" value=\"{$rate}\" />", "betmoney" => $B5hTypeMon, "betflag" => true);
                        }
                        ++$i;
                    }
                    break;
                    $timeTemp = rand(0, 9999);
                    $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-9会员下注:异常的快选行为";
                    write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
                    $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
                    exit();
                    break;
            }
        }
        else
        {
            $timeTemp = rand(0, 9999);
            $errMsg = "({$tbl})[betbeforedo]No.{$timeTemp}-10会员下注:不正确的玩法页面";
            write_exceptional_log($curruser['id'], $curruser['acl'], $lotto_id, $errMsg);
            $ui->showErrorPage("下注失败，若有任何问题请洽管理员(errorNo.{$timeTemp})");
            exit();
        }
    }
    if (intval(getvar("qFast")))
    {
        $qFast = "1";
    }
    else
    {
        $qFast = "";
    }
    if ($qFast)
    {
        $qFastStr = "&qFast={$qFast}";
    }
    else
    {
        $qFastStr = "";
    }
    $ui->header();
    $ui->showNews3D($curruser['acl']);
    echo "<div></div>";
    echo "<form action=\"op.php?op=member_5h&fp=bet_do&palygroup=" . $bettypegroup . "&gametype=" . $gametype . "&disk=" . $disk . "\" method=\"post\" onsubmit=\"this.submit.disabled=true;this.reset.disabled=true\">";
    echo "<input type=\"hidden\" value=\"" . $bettypegroup . "\" name=\"bettypegroup\" />";
    echo "<input type=\"hidden\" value=\"" . $gametype . "\" name=\"gametype\" />";
    echo "<input type=\"hidden\" value=\"" . $xyidGet . "\" name=\"xyid\" />";
    echo "<input type=\"hidden\" value=\"" . $subid . "\" name=\"subid\" />";
    echo "<input type=\"hidden\" value=\"" . $disk . "\" name=\"disk\" />";
    echo "<input type=\"hidden\" value=\"" . $qFast . "\" name=\"qFast\" />";
    if ($rcbettype)
    {
        echo "<input type=\"hidden\" value=\"" . $rcbettype . "\" name=\"rcbettype\" />";
    }
    echo "<table class=\"tblMy3D\">";
    echo "<thead><tr class=\"bgImg_" . $gametype . "\"><th colspan=6>" . $tblName . " 第" . $round . "期 您下注的是：</th></tr>";
    echo "<tr class=\"bgClc_" . $gametype . "\">";
    if (!$_8hFlag)
    {
        echo "<th>XY盘</th>";
    }
    else
    {
        echo "<th>*</th>";
    }
    echo "<th>下注方式</th><th>下注内容</th><th>盘类</th><th>赔率</th><th>下注金额</th></tr></thead>";
    echo "<tbody>";
    $totalmon = 0;
    foreach ($showBetTable as $val)
    {
        echo "<tr class=\"td2\">";
        if (!$_8hFlag)
        {
            echo "<td>" . $g_xyDisk[$val['xyid']] . "</td>";
        }
        else
        {
            echo "<td></td>";
        }
        echo "<td>" . $val['bettype'] . "</td>";
        echo "<td>" . $val['nums'] . "</td>";
        echo "<td>" . $diskStr2 . "</td>";
        echo "<td>" . $val['rate'] . "</td>";
        echo "<td align=\"right\">" . $val['betmoney'] . "</td>";
        if ($val['betflag'])
        {
            $totalmon += $val['betmoney'];
        }
        echo "</tr>";
    }
    $timebtnType = getvar("timebtnType") == "checkbox" ? "checkbox" : "text";
    unset($_POST['timebtnType']);
    $backurl = "op.php?op=member_5h&fp=bet&palygroup={$bettypegroup}&timebtnType={$timebtnType}&gametype={$gametype}&disk={$disk}&xyid={$xyidGet}&subid={$subid}&rcbettype={$rcbettype}{$qFastStr}";
    if (0 < $totalmon)
    {
        echo "<tr class=\"bgClc_" . $gametype . "\" align=\"right\"><td colspan=\"5\">合计</td><td>" . $totalmon . "</td></tr>";
        echo "<tr class=\"bgClc_24\"><td colspan=\"6\" align=\"center\" style=\"color:red;\"><input type=\"checkbox\" name=\"recentNew\" value=\"1\" checked />强制(赔率异动时，依新赔率下注)</td></tr>";
        $btnStr = "<input type=\"submit\" name=\"submit\" value=\"确定下注\" />&nbsp;&nbsp;<input name=\"reset\" type=\"reset\" value=\"取消下注\" onclick=\"javascript:window.top.mainFrame.location.href='" . $backurl . "';\" />";
        $focusStr = "document.forms[0].submit.focus();";
    }
    else
    {
        echo "<tr class=\"red\"><td colspan=\"6\" align=\"center\">无任何可下注资料</td></tr>";
        $btnStr = "<input name=\"reset\" type=\"reset\" value=\"回上一页\" onclick=\"javascript:window.top.mainFrame.location.href='" . $backurl . "';\" />";
        $focusStr = "";
    }
    echo "</tbody>";
    echo "</table>";
    echo $btnStr;
    echo "<input type=\"hidden\" value=\"" . $timebtnType . "\" name=\"timebtnType\" id=\"timebtnType\" />";
    echo "</form>";
    echo "<script>";
    echo $focusStr;
    echo "</script>";
    $ui->footer();
}
?>